package com.health.memberbackstage.pojo.R;


import lombok.Data;

@Data
public class Result {

    private int code;
    private String message;
    private Object data;

    public static Result success(int code, String message, Object data) {
        Result r = new Result();
        r.setCode(code);
        r.setMessage(message);
        r.setData(data);
        return r;
    }

    public static Result success(String message) {
        Result r = new Result();
        r.setCode(200);
        r.setMessage(message);
        return r;
    }

    public static Result success(){
        return Result.success(200,"成功",null);
    }

    public static Result success( Object data){
        return Result.success(200,"成功",data);
    }

    public static Result error(){
        Result r = new Result();
        r.setCode(500);
        r.setMessage("服务器异常");
        return r;
    }

    public static Result error(ResultEnum be){
        Result r = new Result();
        r.setCode(be.getCode());
        r.setMessage(be.getMessage());
        return r;
    }

    public static Result fail(String msg){
        Result r = new Result();
        r.setMessage(msg);
        r.setCode(ResultEnum.FAIL.getCode());
        return r;
    }

    public static Result fail(int code ,String msg){
        Result r = new Result();
        r.setCode(code);
        r.setMessage(msg);
        return r;
    }

    public static Result fail(ResultEnum resultEnum){
        Result r = new Result();
        r.setCode(resultEnum.getCode());
        r.setMessage(resultEnum.getMessage());
        return r;
    }
}